package com.ml.framework.base.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.util.StringUtils;

import com.opensymphony.xwork2.ActionSupport;

/**
 * @filename      : SimplePackAction.java
 * @description   : TODO(一句话描述该类做什么)
 * @author        : wanghongkai
 * @create        : 2013-8-26 下午4:10:38
 * @copyright     : hileto Corporation 2013
 *
 * Modification History:
 * Date             Author       Version
 * --------------------------------------
 * d2013-8-26 下午4:10:38
 */
public class BaseSimplePack extends ActionSupport implements ServletRequestAware, ServletResponseAware
{

	private static final long serialVersionUID = 7801936466701719759L;
	
	protected HttpServletResponse response;
	
	protected HttpServletRequest request;

	@Override
	public void setServletResponse(HttpServletResponse res) {
		response = res;
	}

	@Override
	public void setServletRequest(HttpServletRequest req) {
		request = req;
	}
	
	
	
	
	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}

	/**
	 * 获取请求中的参数值
	 * 
	 * @autor wanghongkai
	 * @param key	参数的key
	 * @param defaultValue	取不到对应值时,返回的默认值
	 * @return
	 */
	protected String getParamValueByKey(String key, String defaultValue)
	{
		String val = request.getParameter(key);
		if(StringUtils.isEmpty(val))
		{
			return defaultValue;
		}
		return val;
	}
}
